#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e5+10;
struct node
{
	int x;
	int y;
	int d;
}a[N];
 int x1,y11,x2,y2;
 int n;
 int ret;
 int r=0x3f3f3f3f;
 int l=0x3f3f3f3f;
 bool cmp(node& a,node& b)
 {
 	return a.d>b.d;
 }
 int calc(int x,int y,int xx,int yy)
 {
 	return (xx-x)*(xx-x)+(yy-y)*(yy-y);//这道题的代价是工作半径的平方和 
 } 
 int main()
 {
 	cin>>x1>>y11>>x2>>y2;
 	cin>>n;
 	for(int i=1;i<=n;i++)
 	{
 		cin>>a[i].x>>a[i].y;
 		a[i].d=calc(a[i].x,a[i].y,x1,y11);
	 }
	 
	 sort(a+1,a+1+n,cmp);
	 
	 r=a[1].d;//距离左边的距离
	 l=0;
	 ret=r;
	for(int i=2;i<=n+1;i++)//注意循环到n+1才能判断最后一个只连右 
	{
		r=a[i].d;//距离左边的距离
		l=max(l,calc(a[i-1].x,a[i-1].y,x2,y2));
		ret=min(ret,l+r); 
	}
 	cout<<ret<<endl;
    return 0;
 }
 